<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <div v-show="!isLogin">
        <input type="button" value="注册">
        <input type="button" value="登入" @click="login()">
    </div>
    <div v-show="isLogin">
        <input type="button" value="登出" @click="logout()">
        <input type="text" v-model="newName" placeholder="请输入员工姓名">
        <input type="button" value="添加" @click="add()">
    </div>
    <lu>
        <li v-for="name in arr">{{name}}</li>
    </lu>
</div>
<!--引入vue框架-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    let v = new Vue({
        el: "body>div",
        data: {
            arr: ["刘备", "关羽", "张飞"],
            isLogin: false,
            newName:""
        },
        methods:{
            login:function () {
                v.isLogin=true;
            },
            logout:function () {
                v.isLogin=false;
            },
            add:function () {
                //往数组添加newName
                v.arr.push(v.newName);
            }
        }
    })
</script>
</body>
</html>